# Contributor: guddaff <guddaff@protonmail.com>
# Maintainer: guddaff <guddaff@protonmail.com>
pkgname=bottom
pkgver=0.6.8
pkgrel=0
pkgdesc="Graphical process/system monitor with a customizable interface"
url="https://github.com/ClementTsang/bottom"
arch="x86_64 armv7 armhf aarch64 x86 ppc64le"  # limited by rust/cargo
license="MIT"
makedepends="cargo"
subpackages="
	$pkgname-fish-completion
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-doc
	"
source="https://github.com/ClementTsang/bottom/archive/$pkgver/bottom-$pkgver.tar.gz
	minimize-size.patch
	"

prepare() {
	default_prepare
	cargo fetch --locked
}

build() {
	cargo build --frozen --release
}

check() {
	CARGO_HUSKY_DONT_INSTALL_HOOKS=true cargo test --frozen
}

package() {
	cargo install --locked --path . --root=$pkgdir/usr
	rm "$pkgdir"/usr/.crates*

	install -Dm644 sample_configs/default_config.toml -t "$pkgdir"/usr/share/doc/$pkgname/

	cd target/release/build/bottom-*/out
	install -Dm644 _btm "$pkgdir"/usr/share/zsh/site-functions/_btm
	install -Dm644 btm.bash "$pkgdir"/usr/share/bash-completion/completions/btm
	install -Dm644 btm.fish "$pkgdir"/usr/share/fish/completions//btm.fish
}

sha512sums="
e414b9c8ce4c5c27ac1f3ac6d29a1dcca2c269b5d6d60d90408324635bf69f5f50947c5ff2dff38fc123939c508c18cb144b14f96d4fd581962770a9b49544dc  bottom-0.6.8.tar.gz
67bd8e4acc4326dfa1a313ce72b2b20d2c11a7894f9fddfafa62151763679578e94d99a51aa3667d64dbc85368453a1e91ae95c78df5809d34c6d49db59c01ff  minimize-size.patch
"
